﻿namespace System.Xml.Serialization.Internal
{
    internal interface IXmlRuntimePropertyReader
    {
        void Read(IXmlPropertyReader propertyReader, IRuntimePropertyWriter property, string propertyName);
    }

    internal interface IXmlRuntimePropertyWriter
    {
        void Write(IXmlPropertyWriter propertyWriter, IRuntimePropertyReader property, string propertyName);
    }

    internal interface IXmlRuntimeReader
    {
        void Read(IXmlReader reader, IXmlPropertyReader node, string propertyName);
    }

    internal interface IXmlRuntimeWriter
    {
        void Write(IXmlWriter writer, IXmlPropertyWriter node, string propertyName);
    }

    internal interface IXmlReader
    {
        void Read(IXmlPropertyReader writer, string propertyName);
    }

    internal interface IXmlWriter
    {
        void Write(IXmlPropertyWriter writer, string propertyName);
    }

    internal interface ITypeLoader
    {
        Type LoadType(string typeName);
    }

    /// <summary>
    /// Сильно-типизированное свойство
    /// </summary>
    /// <typeparam name="T">Параметр</typeparam>
    internal interface IXmlRuntimeProperty<T>
    {
        /// <summary>
        /// Имя свойства
        /// </summary>
        /// <returns>Имя свойства</returns>
        string PropertyName { get; }
        T Value { get; set; }
    }

    /// <summary>
    /// Свойство
    /// </summary>
    internal interface IXmlRuntimeProperty :
        IXmlReader,
        IXmlWriter
    {
        /// <summary>
        /// Имя свойства
        /// </summary>
        /// <returns>Имя свойства</returns>
        string PropertyName { get; }

        IXmlRuntimeProperty<T> GetRuntimeProperty<T>();

        IRuntimePropertyReader Reader { get; }
        IRuntimePropertyWriter Writer { get; }
    }

    internal interface IRuntimePropertyAttributes
    {
        string PropertyName { get; }
        bool CanSerialize { get; }
        bool CanRuntimeSerialize { get; }
        XmlRuntimeSerializer RuntimeSerializer { get; }
    }

    /// <summary>
    /// Свойство
    /// </summary>
    internal interface IRuntimePropertyReader : IXmlReader, IRuntimePropertyAttributes
    {
        /// <summary>
        /// Значение свойства
        /// </summary>
        string Read();
        object ReadObject();
        bool CanRead { get; }
        IRuntimePropertyWriter Writer { get; }
    }

    /// <summary>
    /// Свойство
    /// </summary>
    internal interface IRuntimePropertyWriter : IXmlWriter, IRuntimePropertyAttributes
    {
        /// <summary>
        /// Значение свойства
        /// </summary>
        void Write(string value);
        void WriteObject(object value);
        bool CanWrite { get; }
        IRuntimePropertyReader Reader { get; }
    }

    internal interface IXmlTypeFormatterInternal : IXmlTypeFormatter
    {
        IXmlRuntimeSerializerInternal InternalSerializer { get; }
    }

    internal interface IXmlFormatAttributesInternal : IXmlFormatAttributes
    {
        void Add(Type type, XmlAttributes attributes);
        void Add(Type type, string member, XmlAttributes attributes);

        XmlFormatterValue GetAttributes();
        XmlFormatterValue GetAttributes(string member);
    }

    internal interface IXmlRuntimeSerializerInternal : IXmlTypeSerializer
    {
        IXmlFormatAttributesInternal InternalAttributes { get; }
        XmlSerializer RuntimeSerializer { get; }
        Type RuntimeType { get; }
        void CreateRuntimeSerializer(bool generateNew);
    }
}
